<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>insert_roles</title>
		<meta name="renderer" content="webkit|ie-comp|ie-stand">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<link rel="stylesheet" href="/style/css/font.css">
		<link rel="stylesheet" href="/style/css/weadmin.css" />
		<link rel="stylesheet" href="/lib/layui/css/layui.css" />
		<script type="text/javascript" src="/lib/layui/layui.js" charset="utf-8"></script>
		<script src="/style/js/rbac_Cookie.js"></script>
		<script>
			layui.use(['form'], function() {
				var form = layui.form,
					$ = layui.jquery;
				$(function() {
				/*	
					if(pageloadauthority("/views/insert_roles.html")==true){
						$("body").attr("style","display:block;");
						return;
					}*/
				})   
			});
			  var logintoken=  getSharreTieba_LoginToken();
		</script>
		<style type="text/css">
			.layui-table-tool-panel li .layui-form-checkbox[lay-skin=primary] {
				/* width: 100%; */
				padding-left: 28px;
			}
			.layui-table-tool-panel li {
				line-height: 30px;
				-webkit-transition: .5s all;
				transition: .5s all;
				padding-left: 10px;
				padding-right: 47px;
			}
		</style>
	</head>

	<body>
	
<!--表格-->
<div class="weadmin-body">  

<form class="layui-form" >
  
 <div class="layui-form-item">
    <label class="layui-form-label">角色名称</label>
    <div class="layui-input-inline">
      <input type="text" name="role" required lay-verify="required" placeholder="请输入角色名称" autocomplete="off" class="layui-input">
    </div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">角色描述</label>
    <div class="layui-input-inline">
      <input type="text" name="description" required lay-verify="required" placeholder="请输入角色描述" autocomplete="off" class="layui-input">
    </div>
  </div>
  
   <div class="layui-form-item">
    <label class="layui-form-label">父节点</label>
    <div class="layui-input-inline">
      <input type="number" name="pid" required lay-verify="required" placeholder="请输入父节点" autocomplete="off" class="layui-input">
    </div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">是否锁定</label>
    <div class="layui-input-block">
      <input type="checkbox" name="available" lay-skin="switch" lay-filter="available" lay-text="ON|OFF">
    </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="formsub">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>
  </div>
<script>
//Demo
layui.use('form', function(){
	
  var form = layui.form,
	$ = layui.jquery;
  var  sd=false;
  //监听提交
  form.on('submit(formsub)', function(data){
  	data.field.available=sd;
  
        $.ajax({
        	type:"get",
        	url:"http://localhost:8086/permission/insertRoles",
        	async:false,
        	data:{'LoginKey':logintoken,'data':JSON.stringify(data.field)},
        	success:function(json){
        		 if(json.code==200){
        		 		layer.msg(json.extend.info, {
										icon: 5,
										anim: 6
									});
        		 }else{
        		 	  layer.msg('添加成功!');
        		 }
        	}
        });    
    return false;
  });
  
    //监听指定开关
  form.on('switch(available)', function(data){
  	   sd= this.checked ;
  });
  
});
</script>
</body>
</html>
